package com.steakliu.consumer;

import com.steakliu.interfaces.UserServiceInterface;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.rpc.RpcContext;

/**
 * 功能说明：
 * <p>
 * Original @Author: steakliu-刘牌, 2022-08-28  21:24
 * <p>
 * Copyright (C)2020-2022  steakliu All rights reserved.
 */
public class ConsumerApiMethod {
    public static void main(String[] args) {
        ReferenceConfig<UserServiceInterface> referenceConfig = new ReferenceConfig<>();
        referenceConfig.setInterface(UserServiceInterface.class);
        referenceConfig.setApplication(new ApplicationConfig("dubbo-consumer"));
        referenceConfig.setRegistry(new RegistryConfig("zookeeper://101.201.113.230:2181"));
        referenceConfig.setTimeout(5000);
        referenceConfig.setVersion("1.0.0");
        referenceConfig.setGroup("dubbo");

        UserServiceInterface userServiceInterface = referenceConfig.get();
        RpcContext.getContext().setAttachment("userId", 1);
        System.out.println("result: "+userServiceInterface.getUser("1"));
    }
}
